package com.jiesen.base.baseDao;

import java.io.Serializable;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonIgnore;

import lombok.Data;

@Data
public class BaseModel implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@TableField(exist = false,select = false)
	@JsonIgnore 
    private transient int pageid;

    /**
     * 当前页
     **/
	@TableField(exist = false,select = false)
	//@JsonIgnore
    private  int page;

    /**
     * 每页显示总记录数
     **/
	@TableField(exist = false)
	//@JsonIgnore
    private  int limit;

    /**
     * 每页的开始记录数
     **/
	@TableField(exist = false)
	@JsonIgnore 
    private transient int start;
	@TableField(exist = false)
	@JsonIgnore 
    protected transient long totalCount = -1L;
	@TableField(exist = false)
	@JsonIgnore 
    protected transient long totalSize = 0;


    public int getPage() {
        if (page == 0) {
            return 1;
        }
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getLimit() {
        if (page == 0) {
            return 10;
        }
        return limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
    }

    public int getStart() {
        this.start = (page - 1) * limit;
        return start;
    }

    public long getTotalCount() {
        return this.totalCount;
    }

    public void setTotalCount(long totalCount) {
        this.totalCount = totalCount;
    }

    public long getTotalSize() {
        if (this.totalCount < 0L) {
            return -1L;
        }

        long count = this.totalCount / this.limit;
        if (this.totalCount % this.limit > 0L) {
            count += 1L;
        }
        return count;
    }

}
